package com.quyou.funtour.utils;

import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

public class CopyUtils<T,Q> {

    public List<Q> copy(List<T> list,Class<Q> qClass){
        List<Q> qList = new ArrayList<>();

        for (T t : list) {
            try {
                Q q = qClass.newInstance();
                BeanUtils.copyProperties(t,q);
                qList.add(q);
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
        return qList;

    }

}
